/**
 * @author: LiuHeng
 * @Description:
 * @Date: 2022-08-19 21:58
 */
public class BSNearLeft {
    //在arr中，寻找满足>=value的最左位置
    public static int nearestIndex(int[] arr, int value){
        int l = 0;
        int r = arr.length - 1;
        int index = -1;
        while(l <= r){
            int mid = l + ((r - l) >> 1);
            if (arr[mid] >= value){
                index = mid;
                r = mid - 1;
            }else{
                l = mid + 1;
            }
        }
        return index;
    }

}
